package com.goldcn.enumeration;

import com.google.common.base.Objects;

/**
 * 购买主体
 * Created by Administrator on 2016/10/18.
 */
public enum BuyerEnum {
    SUPPLIER(0,"supplier"),//供应商
    TOPDEPT(1,"topdept"),//总部
    SECONDDEPT(2,"seconddept"),//分部
    THIRDDEPT(3,"thirddept"),//二级分部
    FOURTHDEPT(4,"fourthdept"),//支部
    EMPLOYEE(5,"employee"),//员工
    SALER(6,"saler");//促销员
    private Integer flag;
    private String sFlag;

    BuyerEnum(Integer flag, String sFlag) {
        this.flag = flag;
        this.sFlag = sFlag;
    }

    public Integer getFlag() {
        return flag;
    }

    public void setFlag(Integer flag) {
        this.flag = flag;
    }

    public String getsFlag() {
        return sFlag;
    }

    public void setsFlag(String sFlag) {
        this.sFlag = sFlag;
    }

    public static BuyerEnum valuekOf(Integer flag) {
        for (BuyerEnum buyerEnum : values()) {
            if (Objects.equal(buyerEnum.getFlag(),flag)) {
                return buyerEnum;
            }
        }
        return null;
    }

    /**
     * 是否计算税点
     * @param field
     * @return
     */
    public static boolean isCountTaxRate(String field){
        return Objects.equal(field,BuyerEnum.SALER.getsFlag()) ||
                Objects.equal(field,BuyerEnum.EMPLOYEE.getsFlag()) ||
                Objects.equal(field,BuyerEnum.FOURTHDEPT.getsFlag());
    }

}
